<template>
<div id="blocksDetailed">
        <div class="search_box">
            <div class="container">
                <p>{{ $lang("Block_information") }}</p>
            </div>
        </div>
        <div class="tran_table">
            <div class="container">
                <div class="bread_rumb clearfix">
                    <div class="f_l">
                        <el-breadcrumb separator-class="el-icon-arrow-right">
                        <el-breadcrumb-item :to="{ path: '/' }">{{ $lang('HOME') }}</el-breadcrumb-item>
                        <el-breadcrumb-item :to="{ path: '/blocks' }">{{ $lang('BLOCK_TAB') }}</el-breadcrumb-item>
                        <el-breadcrumb-item>{{ $lang('Block_information') }}</el-breadcrumb-item> 
                        </el-breadcrumb>
                    </div>
                </div>
                <div class="ul">
                        <div class="ulname">{{ $lang('Block_height') }}</div>
                        <div class="ulmsg">{{blockList.blockheight}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('Block_date') }}</div>
                        <div class="ulmsg">{{dateFormat(blockListh.timestamp)}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('Block_producers') }}</div>
                        <div class="ulmsg"><router-link style="cursor: pointer;color: #cca33c;" :to="{path:'/account/receiver/' + blockList.producer }">{{blockList.producer}}</router-link></div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('Last_hash') }}</div>
                        <div class="ulmsg">{{blockListh.hashprevblock}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('Current_hash') }}</div>
                        <div class="ulmsg">{{blockList.blockheight}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('Block_size') }}</div>
                        <div class="ulmsg">{{blockList.blocksize}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('Eggmax') }}</div>
                        <div class="ulmsg">{{blockListh.eggmax}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('BlockReward') }}</div>
                        <div class="ulmsg">{{blockList.blockReward}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('EggUsed') }}</div>
                        <div class="ulmsg">{{blockList.eggUsed}}</div>
                    </div>
                    <div class="ul">
                        <div class="ulname">{{ $lang('VERSION') }}</div>
                        <div class="ulmsg">{{blockListh.version}}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import axios from 'axios';
import { gets, formatTime } from '@/api/api.js';
import url from '@/api/url.js';
export default {
	data(){
		return {
			input:"",
			currentPage:1, // 分页当前页
			pageSize:5, // 每页条数
            blockList: [],
            blockListh: []
		}
	},
	mounted(){
		this.getBlockByBlockHeight();
	},
	methods:{
		changePage(currentPage){
			this.currentPage = currentPage;
			this.getPageList();
        },
        getBlockByBlockHeight(type){
            let that = this
            const loading = this.$loading({
                text: that.$lang('loading'),
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            axios.get(url.urlblockH + '/block/getBlockByHashSearch', {
                params: {
                    blockhash: this.$route.params.id,
                }
            })
            .then(function (res) {
                that.blockList = res.data.data
                that.blockListh = res.data.data.blockheader
                loading.close()
            })
            .catch(function (error) {
                loading.close()
                console.log(error);
            })
        },
        // 格式日期
        dateFormat(val) {
            if (val === undefined) {
                return false
            } else {
                let time = JSON.parse(val)
                return formatTime(new Date(time), 'yyyy-MM-dd hh:mm:ss')
            }
        }
	}
	
}
</script>
<style lang="scss" >
@import '~assets/scss/blocksDetailed.scss';
.el-breadcrumb__inner{
    color: #fff !important;
}
</style>